package com.zhuang.chapter10.work02;

import java.util.Arrays;

@SuppressWarnings("serial")
public class ArrayLengthNotZeroException extends RuntimeException {
	public ArrayLengthNotZeroException(String message) {
		super(message);
	}

	public static int getMax(int[] arr) {
		if (arr.length == 0) {
			throw new ArrayLengthNotZeroException("数组长度不能为0!!!");
		}
		Arrays.sort(arr);
		return arr[arr.length - 1];
	}

	public static void main(String[] args) {
		int arr[] = { 1, 6, 3 };
		int max = getMax(arr);
		System.out.println("最大值为：" + max);
		int arr2[] = new int[0];
		int max2 = getMax(arr2);
		System.out.println("最大值为：" + max2);
	}
}
